package Chapter3;

import java.text.DecimalFormat;
import java.util.Scanner;

//64页程序3.4 3.6
public class OutScanner {
    public static void main(String[] args) {

        System.out.println("请输入您的身高（m）：");
        Scanner scanner = new Scanner(System.in);

        double height = scanner.nextDouble();
            if (height<1 || height>2){
            System.out.println("身高参数出错！");
            return;
            }
        System.out.println("请输入您的体重（kg）：");

        double weight = scanner.nextDouble();
             if (weight<40 || weight>200){
            System.out.println("体重参数出错！");
            return;
            }

        double BMI = weight/(height*height);
        DecimalFormat fmt = new DecimalFormat("0.##");
        System.out.println("您的BMI是："+fmt.format(BMI));
            if (BMI>0 && BMI<=18.5){
            System.out.println("您偏瘦了");
            }else if(BMI>18.5 && BMI<=24) {
            System.out.println("BMI正常");
            }else if (BMI>24 && BMI<30){
            System.out.println("您偏胖了");
            }else{
            System.out.println("参数错误");
            }
    }
}
